import requests
import time

# 公共Headers
common_headers_messageJW = {
    "Accept": "application/json, text/plain, */*",
    "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
    "Authorization": "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjAzYWFjYzJhLTA5YTYtNDQxNy1hZTFhLWQwNDg2MGEwNWRhZCJ9.qw-K05fiEoD-Stj392h8eR-7zF1r4QkEzV320Qb9463saH5Bfy2YCgmTBQfeM4sgAq98K7MNY_T5J1G7Jwaarg",
    "Connection": "keep-alive",
    "Content-Type": "application/json",
    "Origin": "http://69.231.135.101",
    "Referer": "http://69.231.135.101/pgktjwsnew/",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0"
}

common_headers_log = {
    "Accept": "*/*",
    "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
    "Connection": "keep-alive",
    "Content-Type": "application/json;charset=UTF-8",
    "Origin": "http://69.231.135.101",
    "Referer": "http://69.231.135.101/",
    "Sec-Fetch-Dest": "empty",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Site": "cross-site",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0",
    "sec-ch-ua": "\"Chromium\";v=\"136\", \"Microsoft Edge\";v=\"136\", \"Not.A/Brand\";v=\"99\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "x-log-apiversion": "0.6.0",
    "x-log-bodyrawsize": "3551",
}

# 请求列表
requests_list = [
    # 1. 状态 waiting
    {
        "url": "http://69.231.135.101/pgktstudent/messageJW/send",
        "headers": common_headers_messageJW,
        "json": {
            "key": "d6F0EMViVeP9dUzcceYTsUhaqAQMndqvCsWHyeP/j/cVDfuamQ+2p3KR4l/Z1YG59C3eLtER2ZPMfP+Nsh2l4GDCW0Hci1L5V1WEJYpfWCJelU/1XBhNIPrVGylzcyFMfnUIdr8+9RRj4AaKHuiH0hgzI/s/8eml1PayZ24ZO4FLoMCdUE82E6yuMGlqysqC0QPoUYYy9y9AmDxv57gM7w==",
            "id": "ed755ee8f42f4c62873a73cc4bcde93c",
            "playPosition": 0,
            "playRatio": 0,
            "playStatus": "waiting",
        },
        "verify": False
    },
    # 2. 上报日志（可按需替换body）
    {
        "url": "https://videocloud.cn-hangzhou.log.aliyuncs.com/logstores/newplayer/track",
        "headers": common_headers_log,
        "json": {
            "__logs__": [
                {
                    "APIVersion": "0.6.0",
                    "t": "1747812814773",
                    "ll": "info",
                    "lv": "1.0",
                    "pd": "player",
                    "md": "saas_player",
                    "ui": "saas_player",
                    "sm": "play",
                    "os": "windows",
                    "ov": "10",
                    "et": "EdgeChromium",
                    "ev": "136.0.0.0",
                    "uat": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0",
                    "hn": "",
                    "bi": "",
                    "ri": "FC5C8A31-EE17-49E5-ACE5-EC8FAA8D9A66",
                    "e": "9002",
                    "args": "log=[base/player.js]doSeek::0",
                    "li_ki": "",
                    "vt": "vod",
                    "tt": "pc",
                    "dm": "h5",
                    "av": "2.19.0",
                    "uuid": "8438159D-D35B-4A3A-B2AF-5FD45578AC55",
                    "vu": "https://s3.cn-northwest-1.amazonaws.com.cn/syzx/pgkc_image/fixed_20231021142945A393.mp4",
                    "vd": "s3.cn-northwest-1.amazonaws.com.cn",
                    "ua": "0",
                    "dn": "custom",
                    "cdn_ip": "",
                    "app_n": "69.231.135.101",
                    "r": "",
                    "pu": "http://69.231.135.101/pgktjwsnew/#/videoPlay?curCourse=CSS%E5%9F%BA%E7%A1%80&type=1&id=ed755ee8f42f4c62873a73cc4bcde93c&key=d6F0EMViVeP9dUzcceYTsUhaqAQMndqvCsWHyeP%2Fj%2FcVDfuamQ%2B2p3KR4l%2FZ1YG59C3eLtER2ZPMfP%2BNsh2l4GDCW0Hci1L5V1WEJYpfWCJelU%2F1XBhNIPrVGylzcyFMfnUIdr8%2B9RRj4AaKHuiH0hgzI%2Fs%2F8eml1PayZ24ZO4FLoMCdUE82E6yuMGlqysqC0QPoUYYy9y9AmDxv57gM7w%3D%3D&playPosition=338.166667",
                    "ti": "",
                    "en": "TRACE",
                    "__time__": 1747812815
                }
            ],
            "__source__": ""
        },
        "verify": True
    },
    # 3. 状态 playing，playPosition变化
    {
        "url": "http://69.231.135.101/pgktstudent/messageJW/send",
        "headers": common_headers_messageJW,
        "json": {
            "key": "d6F0EMViVeP9dUzcceYTsUhaqAQMndqvCsWHyeP/j/cVDfuamQ+2p3KR4l/Z1YG59C3eLtER2ZPMfP+Nsh2l4GDCW0Hci1L5V1WEJYpfWCJelU/1XBhNIPrVGylzcyFMfnUIdr8+9RRj4AaKHuiH0hgzI/s/8eml1PayZ24ZO4FLoMCdUE82E6yuMGlqysqC0QPoUYYy9y9AmDxv57gM7w==",
            "id": "ed755ee8f42f4c62873a73cc4bcde93c",
            "playPosition": 113.743261,
            "playRatio": 0.33635266896367405,
            "playStatus": "playing",
        },
        "verify": False
    },
    # 4. 状态 playing，playPosition再变化
    {
        "url": "http://69.231.135.101/pgktstudent/messageJW/send",
        "headers": common_headers_messageJW,
        "json": {
            "key": "d6F0EMViVeP9dUzcceYTsUhaqAQMndqvCsWHyeP/j/cVDfuamQ+2p3KR4l/Z1YG59C3eLtER2ZPMfP+Nsh2l4GDCW0Hci1L5V1WEJYpfWCJelU/1XBhNIPrVGylzcyFMfnUIdr8+9RRj4AaKHuiH0hgzI/s/8eml1PayZ24ZO4FLoMCdUE82E6yuMGlqysqC0QPoUYYy9y9AmDxv57gM7w==",
            "id": "ed755ee8f42f4c62873a73cc4bcde93c",
            "playPosition": 233.742288,
            "playRatio": 0.6912043995158162,
            "playStatus": "playing",
        },
        "verify": False
    },
    # 5. 上报日志（可按需替换body）
    {
        "url": "https://videocloud.cn-hangzhou.log.aliyuncs.com/logstores/newplayer/track",
        "headers": common_headers_log,
        "json": {
            "__logs__": [
                {
                    "APIVersion": "0.6.0",
                    "t": "1747813152994",
                    "ll": "info",
                    "lv": "1.0",
                    "pd": "player",
                    "md": "saas_player",
                    "ui": "saas_player",
                    "sm": "play",
                    "os": "windows",
                    "ov": "10",
                    "et": "EdgeChromium",
                    "ev": "136.0.0.0",
                    "uat": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0",
                    "hn": "",
                    "bi": "",
                    "ri": "FC5C8A31-EE17-49E5-ACE5-EC8FAA8D9A66",
                    "e": "2003",
                    "args": "vt=338166",
                    "li_ki": "",
                    "vt": "vod",
                    "tt": "pc",
                    "dm": "h5",
                    "av": "2.19.0",
                    "uuid": "8438159D-D35B-4A3A-B2AF-5FD45578AC55",
                    "vu": "https://s3.cn-northwest-1.amazonaws.com.cn/syzx/pgkc_image/fixed_20231021142945A393.mp4",
                    "vd": "s3.cn-northwest-1.amazonaws.com.cn",
                    "ua": "0",
                    "dn": "custom",
                    "cdn_ip": "",
                    "app_n": "69.231.135.101",
                    "r": "",
                    "pu": "http://69.231.135.101/pgktjwsnew/#/videoPlay?curCourse=CSS%E5%9F%BA%E7%A1%80&type=1&id=ed755ee8f42f4c62873a73cc4bcde93c&key=d6F0EMViVeP9dUzcceYTsUhaqAQMndqvCsWHyeP%2Fj%2FcVDfuamQ%2B2p3KR4l%2FZ1YG59C3eLtER2ZPMfP%2BNsh2l4GDCW0Hci1L5V1WEJYpfWCJelU%2F1XBhNIPrVGylzcyFMfnUIdr8%2B9RRj4AaKHuiH0hgzI%2Fs%2F8eml1PayZ24ZO4FLoMCdUE82E6yuMGlqysqC0QPoUYYy9y9AmDxv57gM7w%3D%3D&playPosition=338.166667",
                    "ti": "",
                    "en": "PAUSE",
                    "__time__": 1747813153
                }
            ],
            "__source__": ""
        },
        "verify": True
    },
    # 6. 状态 ended
    {
        "url": "http://69.231.135.101/pgktstudent/messageJW/send",
        "headers": common_headers_messageJW,
        "json": {
            "key": "d6F0EMViVeP9dUzcceYTsUhaqAQMndqvCsWHyeP/j/cVDfuamQ+2p3KR4l/Z1YG59C3eLtER2ZPMfP+Nsh2l4GDCW0Hci1L5V1WEJYpfWCJelU/1XBhNIPrVGylzcyFMfnUIdr8+9RRj4AaKHuiH0hgzI/s/8eml1PayZ24ZO4FLoMCdUE82E6yuMGlqysqC0QPoUYYy9y9AmDxv57gM7w==",
            "id": "ed755ee8f42f4c62873a73cc4bcde93c",
            "playPosition": 338.166667,
            "playRatio": 1,
            "playStatus": "ended",
        },
        "verify": False
    },
]

def main():
    for idx, req in enumerate(requests_list):
        try:
            print(f"Sending request {idx+1}: {req['url']}")
            resp = requests.post(
                req["url"],
                headers=req["headers"],
                json=req["json"],
                verify=req.get("verify", True),
                timeout=10
            )
            print(f"Status: {resp.status_code}, Response: {resp.text[:200]}...")
            #time.sleep(1)  # 可根据需求调整间隔
        except Exception as e:
            print(f"Error on request {idx+1}: {e}")

if __name__ == "__main__":
    while 1:
        main()